package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.CostPrice;
import com.eling.elcms.travel.service.ICostPriceManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class CostPriceController extends BaseFormController {
	
	@Autowired
	private ICostPriceManager costPriceManager;
	
	
	@RequestMapping("/api/costprice/save")
	@ResponseBody
	public CostPrice save(@ModelAttribute @ModelFilling CostPrice costPrice){
		return costPriceManager.save(costPrice);
	}
	
	
	@RequestMapping("/api/costprice/{pkCostPrice}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkCostPrice){
		costPriceManager.remove(pkCostPrice);
		return new Msg("删除成功");
	}
	
	
	@RequestMapping("/api/costprice/query")
	@ResponseBody
	public List<CostPrice> query(@ModelAttribute CostPrice costPrice){
		return costPriceManager.query(costPrice);
	}
	
	@RequestMapping("/api/costprice/search*")
	@ResponseBody
	public List<CostPrice> search(@ModelAttribute SearchCondition sc,@ModelAttribute CostPrice costPrice){
		sc.setQueryCondition(costPrice);
		return costPriceManager.search(sc);
	}
	
}
